import React, { Component } from "react";
import Son from "./Son";
import myContext from "./utils/myContext";

export default class Index extends Component {

    state={
        lang:"en"   
    }

    changeLang=()=>{
        this.setState({
            lang:this.state.lang==="en"?"zh":"en"
        })
    }

  render() {
    return (
      <myContext.Provider value={this.state}>
        <div>
          <h1>父组件</h1>
          <input type="button" value="修改语言" onClick={this.changeLang} />
          <Son></Son>
        </div>
     </myContext.Provider>
    );
  }
}
